﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Markup;

namespace _11_01_Binding.Common
{
	/// <summary>
	/// 用虚方法转换器能在xmal里直接使用
	/// 
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public abstract class BaseValueConverter<T> : MarkupExtension,IValueConverter where T : class,new()
	{
		private static T Converter = null;
		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			if(Converter == null)
			{
				Converter = new T ();
			}
			return Converter;
		}
		public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture);
		

		public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			throw new NotImplementedException();
		}

		
	}
}
